package com.captainbank.tcl.tclapplication.model;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;

/**
 * Created by TCL on 2019/10/15.
 * Describe:
 */
@Entity
public class PersonDB {
    @Id(autoincrement = true)
    private long id;

    private String name;
    @Unique
    private long inCard;
    private int age;
    @NotNull
    private boolean isMan;
    @Property(nameInDb = "SKILL_ID")
    private long skillId;
    @ToOne(joinProperty = "skillId")
    private SkillDB skillDB;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1011779696)
    private transient PersonDBDao myDao;

    @Generated(hash = 1641835113)
    private transient Long skillDB__resolvedKey;
    @Generated(hash = 1155417550)
    public PersonDB(long id, String name, long inCard, int age, boolean isMan,
            long skillId) {
        this.id = id;
        this.name = name;
        this.inCard = inCard;
        this.age = age;
        this.isMan = isMan;
        this.skillId = skillId;
    }
    @Generated(hash = 59343024)
    public PersonDB() {
    }
    public long getId() {
        return this.id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public long getInCard() {
        return this.inCard;
    }
    public void setInCard(long inCard) {
        this.inCard = inCard;
    }
    public int getAge() {
        return this.age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public boolean getIsMan() {
        return this.isMan;
    }
    public void setIsMan(boolean isMan) {
        this.isMan = isMan;
    }
    public long getSkillId() {
        return this.skillId;
    }
    public void setSkillId(long skillId) {
        this.skillId = skillId;
    }
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1687823654)
    public SkillDB getSkillDB() {
        long __key = this.skillId;
        if (skillDB__resolvedKey == null || !skillDB__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SkillDBDao targetDao = daoSession.getSkillDBDao();
            SkillDB skillDBNew = targetDao.load(__key);
            synchronized (this) {
                skillDB = skillDBNew;
                skillDB__resolvedKey = __key;
            }
        }
        return skillDB;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1052647914)
    public void setSkillDB(@NotNull SkillDB skillDB) {
        if (skillDB == null) {
            throw new DaoException(
                    "To-one property 'skillId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.skillDB = skillDB;
            skillId = skillDB.getId();
            skillDB__resolvedKey = skillId;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 865850734)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getPersonDBDao() : null;
    }

}
